/**
 * Copyright 2007 Christian Mueller
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 * use this file except in compliance with the License. You may obtain a copy of 
 * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by 
 * applicable law or agreed to in writing, software distributed under the License 
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 * 
 * Description:
 * This file provide the logging mechanism for this application
 * 
 */

#ifndef LOGGING_H_
#define LOGGING_H_

/* Just define the loglevels are usable here */

typedef enum {
	LOG_FATAL,
	LOG_ERROR,
	LOG_WARN,
	LOG_INFO,
	LOG_DEBUG0,
	LOG_DEBUG1,
	LOG_DEBUG2,
	LOG_DEBUG3,
	LOG_DEBUG4
} loglevel;

/* the following functions are available */
loglevel logging_get_loglevel();
void logging_set_loglevel(loglevel newLevel);
const char* logging_get_current_logname();
void logging_write_log(loglevel level, const char* message);
void logging_set_applicationName(const char* newName);

/* Define shortcuts */
#define LOG_FATAL(x) logging_write_log(LOG_FATAL,x);
#define LOG_ERROR(x) logging_write_log(LOG_ERROR,x);
#define LOG_WARN(x) logging_write_log(LOG_WARN,x);
#define LOG_INFO(x) logging_write_log(LOG_INFO,x);
#define LOG_DEBUG0(x) logging_write_log(LOG_DEBUG0,x);
#define LOG_DEBUG1(x) logging_write_log(LOG_DEBUG1,x);
#define LOG_DEBUG2(x) logging_write_log(LOG_DEBUG2,x);
#define LOG_DEBUG3(x) logging_write_log(LOG_DEBUG3,x);
#define LOG_DEBUG4(x) logging_write_log(LOG_DEBUG4,x);

extern loglevel current_level;
#define HAS_FATAL (LOG_FATAL<=current_level)
#define HAS_ERROR (LOG_ERROR<=current_level)
#define HAS_WARN (LOG_WARN<=current_level)
#define HAS_INFO (LOG_INFO<=current_level)
#define HAS_DEBUG0 (LOG_DEBUG0<=current_level)
#define HAS_DEBUG1 (LOG_DEBUG1<=current_level)
#define HAS_DEBUG2 (LOG_DEBUG2<=current_level)
#define HAS_DEBUG3 (LOG_DEBUG3<=current_level)
#define HAS_DEBUG4 (LOG_DEBUG4<=current_level)




#endif /*LOGGING_H_*/
